home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / news / readers / nn-tk.001 / nn-tk~ / nn / tcl / exmh_inter.tcl < prev    next >
Text File  |  1996-03-04  |  6KB  |  248 lines

  1. proc Exmh_Focus {} {
  2. }
  3.  
  4. proc Label_Message { text } {
  5. }
  6.  
  7. proc Msg_Redisplay { draft } {
  8. }
  9.  
  10. proc nn_send {draft t} {
  11.     global aux_dir aux_prog aux_POST sedit aux_MAILER msg
  12.  
  13.     set id [SeditId $draft]
  14.  
  15.     set msg(path) "$aux_dir/$draft"
  16.  
  17.     if {$sedit(autoSign) && ($sedit($t,sigfile) != "") && 
  18.     ![info exists exmh($id,mhannodist)]} {
  19.     set b .sedit${id}.but
  20.     eval [option get $b.sign command {}] $sedit($t,sigfile)
  21.     }
  22.  
  23.     SeditSave "$draft" $t
  24. #    SeditSave "$aux_dir/$draft" $t
  25.     if {$sedit($t,8bit)} {
  26.     # Turn on automatic quoting if we've entered 8-bit characters.
  27.     if {$sedit($t,quote) < 0} {
  28.         set sedit($t,quote) 1
  29.     }
  30.     }
  31.     if {$sedit($t,quote) > 0} {
  32.     SeditSendQuotePrintable $draft $t
  33.     }
  34.  
  35.     if {[info commands Misc_PostProcess] != ""} {
  36. #      exmh 1.6
  37.     set in [open "$draft"  r]
  38.     set mailheader [Misc_GetHeader $in]
  39.     close $in
  40.  
  41.     # call the pgp postprocesing if necessary
  42.     set hdrIndex [lsearch -glob $mailheader "pgp-action:*"]
  43.     if {($hdrIndex >= 0) &&
  44.             ![regexp -nocase {^[^ ]*: *none} [lindex $mailheader $hdrIndex]]} {
  45.         Pgp_Process "$draft" "$draft"
  46.     }
  47.     } else {
  48.     Pgp_Process "$draft"
  49.     }
  50.  
  51.     if {$aux_prog == "post" || $aux_prog == "follow"} {
  52.     eval "exec $aux_POST $draft"
  53.     } elseif {$aux_prog == "mail" || $aux_prog == "reply" \
  54.         || $aux_prog == "forward"} {
  55.     eval "exec $aux_MAILER <$draft"
  56.     }
  57.     if {!$sedit($t,keep)} {
  58.     SeditQuit "$draft" $t
  59.     }
  60. }
  61.  
  62.  
  63. proc ExwinFixupFtextLines { args } {
  64.     puts ExwinFixupFtextLines 
  65. }
  66.  
  67.  
  68. proc nn_PreferencesSave {} {
  69.     global nn_x_dir
  70. # need .pref to stop PreferencesDismiss aborting
  71.     if {![winfo exists .pref]}  {
  72.     toplevel .pref
  73.     wm withdraw .pref} 
  74. #    puts "nn_PreferencesSave";
  75.     PreferencesSave
  76.     catch {destroy .pref}
  77.     if [catch {option readfile "$nn_x_dir/tcl/nn-defaults" startup} err] {
  78.     tkerror "nn-defaults error: $err"
  79.     }
  80. }
  81.  
  82. proc SeditReadPref {} {
  83.     global sedit
  84.     set sedit(key,selpaste) {<Control-y> <Button-2>}
  85.     set sedit(scrollButton) ShiftMiddle
  86.  
  87.     if [file exists $sedit(dotfile)] {
  88.     if [catch {uplevel #0 source [glob $sedit(dotfile)]} msg] {
  89.         Exmh_Status "Error in $sedit(dotfile): $msg"
  90.         return
  91.     } 
  92.     }
  93. }
  94.  
  95. proc exmh_init {} {
  96.     global nn_directory  nn_x_dir
  97.     global mime widgetText exmh msg mhProfile
  98.     global widgetText env pref sedit pgp exwin mailcap_default
  99.  
  100.     if {! [info exists env(USER)]} {
  101.     set env(USER) dummy
  102.     }
  103.  
  104.     if [catch {tk colormodel .}] {
  105.         rename tk tk-orig
  106.         proc tk { option args } {
  107.             switch -- $option {
  108.                 colormodel {
  109.                     if {[winfo depth $args] > 4} {
  110.                         return color
  111.                     } else {
  112.                         return monochrome
  113.                     }
  114.                 }
  115.                 default {
  116.                     return [eval {tk-orig $option} $args]
  117.                 }
  118.             }
  119.         }
  120.     }
  121.  
  122. #    catch {
  123.     ExmhResources
  124. #    }
  125.  
  126.     if [info exists env(MH)] {
  127.         set mhProfile(profile) $env(MH)
  128.     } else {
  129.         set mhProfile(profile) $env(HOME)/.mh_profile
  130.     }
  131.  
  132.     set mailcap_default /etc/mailcap
  133.     set exwin(ftextLines) 1
  134.     
  135.     set mime(dir) /usr/local/bin
  136.     set pgp(path) /usr/local/bin
  137.  
  138.     set exmh(version) nn-tk.9
  139.     set exmh(library) $nn_x_dir/tcl/exmh
  140.     set exmh(folder)  $nn_directory
  141.     set exmh(userLibrary)  $nn_directory
  142.  
  143.     set mhProfile(draft-folder) .
  144.     set mhProfile(header-suppress) {}
  145.     set mhProfile(header-display) {}
  146.  
  147.     set msg(id) 1
  148.     set sedit(sigfileDefault) .signature
  149.  
  150.     set pref(uid) 0
  151.     set pref(panes) {}
  152.     set pref(helpInOneWindow) 1
  153.  
  154.     set pref(appDefaults) $nn_x_dir/tcl/exmh/app-defaults
  155.     set pref(userDefaults) $nn_directory/tk-config
  156.  
  157.     if {![info exists env(TMPDIR)] || ![file isdirectory $env(TMPDIR)]} {
  158.         set env(TMPDIR) /tmp
  159.     }
  160.     set pref(localDefaults) $pref(appDefaults).local
  161.  
  162.     PreferencesReadFile $nn_x_dir/tcl/exmh/app-defaults startup
  163.  
  164.     Preferences_Resource msg(tagnames) m_tagnames general
  165.  
  166.     Sedit_Init
  167.     Mime_Init
  168.     Fdisp_Init
  169.     catch {
  170.     Pgp_Init
  171.     }
  172.     catch {
  173.     fileselect_Init
  174.     }
  175.     Widget_TextInit
  176.     Exwin_Init
  177.     Busy_Init
  178.     Sedit_BindInit
  179.     catch {
  180.     TextButton_Init
  181.     }
  182.     catch {
  183.     URI_Init
  184.     }
  185.  
  186.     Mh_Preferences
  187. #    puts $pref(panes)
  188.     if {[info exists pref(WWW,text)]} {
  189.     set pref(panes) {"Simple Editor" MIME  "WWW" "FS Box"}
  190.     } else {
  191.     set pref(panes) {"Simple Editor" MIME  "URI" "FS Box"}
  192.     }
  193.     set addpgp 1
  194.     catch {
  195. #      in case pgp(enabled) not defined
  196.     if {!$pgp(enabled)} {
  197.     set addpgp 0
  198.     }
  199.     }
  200.     if {$addpgp} {
  201.     append pref(panes) { "PGP interface"}
  202.     }
  203. }
  204.  
  205. proc start_mime {t} {
  206.     .more.t configure -wrap word
  207.     MsgShowInText .more.t $t
  208. }
  209.  
  210. proc clear_mime {} {
  211.     Mime_Cleanup .more.t
  212.     .more.t configure -state normal
  213.     more_tags
  214.     .more.t configure -wrap none
  215. }
  216.  
  217. proc do_send {prog tmp} {
  218.     global  aux_WORK sedit
  219.     global aux_dir aux_prog
  220.     upvar mhProfile mhProfile
  221.  
  222.     set aux_prog $prog
  223. puts "aaux=$aux_WORK"
  224.     set n [string last "/" $aux_WORK]
  225.     set aux_dir [string range $aux_WORK 0 [expr $n-1]]
  226.     set t_file  [string range $aux_WORK  [expr $n+1] end]
  227.     set mhProfile(path) $aux_dir
  228.  
  229.     set cur_dir [pwd]
  230.     cd $aux_dir
  231.  
  232.     if {$aux_prog == "post" || $aux_prog == "follow"} {
  233.     set sn [nn_get_var append-signature-post]
  234.     } elseif {$aux_prog == "mail" || $aux_prog == "reply" || $aux_prog == "forward" } {
  235.     set sn [nn_get_var append-signature-mail]    
  236.     }
  237.     if {$sn == "on"} {
  238.     set sedit(autoSign) 1
  239.     } else {
  240.     set sedit(autoSign) 0
  241.     }
  242.  
  243.     Sedit_Start $aux_WORK
  244. #    Sedit_Start $t_file
  245.     cd $cur_dir
  246. }
  247.  
  248.